package com.github.permissiondog.cancanpandroid.util;

import com.github.permissiondog.cancanpandroid.repository.LocalRepository;
import com.github.permissiondog.cancanpandroid.repository.impl.LocalRepositoryImpl;

import java.util.List;

import okhttp3.Cookie;
import okhttp3.CookieJar;
import okhttp3.HttpUrl;

public class MyCookieJar implements CookieJar {

    @Override
    public void saveFromResponse(HttpUrl url, List<Cookie> cookies) {
        LocalRepositoryImpl.getInstance().saveCookies(cookies);
    }

    @Override
    public List<Cookie> loadForRequest(HttpUrl url) {
        return LocalRepositoryImpl.getInstance().getCookies();
    }
}
